<%@ page import="java.util.*, java.io.*, git.common.*, java.sql.PreparedStatement
	, git.etl.RecursiveFilesImporter, git.etl.IFileHandler 
	, git.etl.acc.AccReportHtmlReader, git.etl.acc.AccReportTextReader
	, git.etl.Dao, java.sql.Connection, java.sql.ResultSet, java.sql.Statement" 
%><jsp:useBean id="oLogon" class="git.bankview.wl.bean.LogonBean" scope="session" 
/><%
	request.setCharacterEncoding("iso8859_1"); 
	String transid = request.getParameter("transid");
	//git.bankview.wl.auth.UserAuth.validate(oLogon, transid, 1);

	int labelorder = Integer.parseInt(transid);
	String fileName = request.getParameter("file");
	System.out.println("from - " + fileName);
	fileName = new String(fileName.getBytes("iso8859_1"), "utf8");
	System.out.println("to - " + fileName);
	File f = new File(fileName);
	fileName = f.getName();
	String extName = fileName.substring(fileName.lastIndexOf('.'));
	String extParam = request.getParameter("ext");

	if (".xls".equalsIgnoreCase(extName) || "xls".equals(extParam))
		response.setContentType("application/vnd.ms-excel;charset=ISO-8859-1");
	else if (".htm".equalsIgnoreCase(extName) || "htm".equals(extParam)
		|| ".html".equalsIgnoreCase(extName))
		response.setContentType("text/html;charset=ISO8859_1");
	else if (".mht".equalsIgnoreCase(extName) || "mht".equals(extParam)
		|| ".mhtml".equalsIgnoreCase(extName))
		response.setContentType("message/rfc822;charset=ISO8859_1");
	else if (".txt".equalsIgnoreCase(extName) || "txt".equals(extParam))
		response.setContentType("text/plain;charset=ISO8859_1");
	else if (".pdf".equalsIgnoreCase(extName) || "pdf".equals(extParam))
		response.setContentType("application/pdf;charset=ISO8859_1");
	else
		response.setContentType("application/unknown;charset=iso8859_1");

	response.flushBuffer();
	
	String appRoot = application.getRealPath("/WEB-INF/pub/");
	FileInputStream fs = new FileInputStream(new File(appRoot + "/" + transid + "/" + fileName));
	
	OutputStream os = response.getOutputStream();
	
	byte[] buff = new byte[1024];
	int count = 0;
	while(0 <= (count = fs.read(buff, 0, buff.length)))
	{
		os.write(buff, 0, count);
	}
%>
